package com.golf.core.course.bodies;

import java.util.Formatter;

/**
 * An immutable Vector in coordinate space.
 * 
 * @author gfloodgate
 */
public class Vector 
{
    
    /** The vector that represents no motion. */
    public static final Vector STATIONARY = new Vector(0.0f, 0.0f);
	
    
	/** The angle of this vector. */
	private final float angle;

	/** The speed of this vector. */
	private final float speed;

	
	/**
	 * Create a vector.
	 * 
	 * @param angle The angle of this vector.
	 * @param speed The speed of this vector.
	 */
	public Vector(final float angle, final float speed)
	{
		this.angle = angle;
		this.speed = speed;
	}
	
	
	/**
	 *
	 * 
	 * @return
	 */
	public float getAngle()
	{
		return angle;
	}
	
	
	/**
	 * 
	 * 
	 * @return
	 */
	public float getSpeed()
	{
		return speed;
	}
	
	
	/**
	 * {@inheritDoc}
	 */
	public String toString()
	{
		final StringBuilder buffer = new StringBuilder();
		final Formatter f = new Formatter(buffer);
		f.format("%3.0f\u00B0 (%3.0f)", 180 + Math.toDegrees(angle), speed);	
		
		return buffer.toString();
	}
	
}
